package jmine.tec.datadigester.positional.checker.types;

import java.lang.reflect.Method;

import jmine.tec.datadigester.positional.annotations.PositionalLongEntry;
import jmine.tec.datadigester.positional.checker.PositionalTypeChecker;
import jmine.tec.datadigester.positional.checker.PositionalTypeRange;

import org.apache.commons.lang.ClassUtils;


/**
 * @author israel.crisanto
 */
public class LongPositionalTypeChecker implements PositionalTypeChecker<PositionalLongEntry> {

    public boolean verifyIfMethodIsOk(Method method) {
        return !((method.getParameterTypes().length != 1) || (ClassUtils.primitiveToWrapper(method.getParameterTypes()[0]) != Long.class));
    }

    public PositionalTypeRange getRange(PositionalLongEntry annotation, Method method) {
        return new PositionalTypeRange(method, annotation.start(), annotation.size());
    }

}
